package cn.edu.shiep.util;

public class PageInfo {
	private int currentPage = 1;
	private int totalPage;
	private int pageSize = 10;
	private long totalSize;
	public int getCurrentPage() {
		return currentPage;
	}
	public void setCurrentPage(int currentPage) {
		if(currentPage <= 0) {
			this.currentPage = 1;
		} else {
			this.currentPage = currentPage;
		}
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public long getTotalSize() {
		return totalSize;
	}
	public void setTotalSize(long totalSize) {
		this.totalSize = totalSize;
		this.totalPage = (int) (totalSize % pageSize == 0 ? totalSize / pageSize : totalSize / pageSize + 1);
	}
	@Override
	public String toString() {
		return "pageInfo";
	}
	public int getPrevPageNumber() {
		int returnResult = 1;
		if(currentPage >= 1) {
			returnResult = currentPage - 1;
		}
		return returnResult;
	}
	public int getNextPageNumber() {
		int returnResult = totalPage;
		if(currentPage < totalPage) {
			returnResult = currentPage + 1;
		}
		return returnResult;
	}
	public int getStart() {
		return (currentPage - 1) * pageSize;
	}
	
}
